import { sendEmailCode } from '@/api/flow/auth';

export default {
  data() {
    return {
       // send code
       isSendCode: false
    };
  },

  computed: {
    codeText() {
      return this.isSendCode ? 'Verification code sent' : 'Send Verification Code';
    }
  },

  methods: {
    // sendCode
    sendCode() {
      this.form.validateFields(['email'], (errors, values) => {
        if (!errors) {
          this.isSendCode = true;
          const email = this.form.getFieldValue('email');
          sendEmailCode(email)
            .catch(() => {
              this.isSendCode = false;
            });
        }
      });
    }
  }
};
